import Vue from 'vue'
import VueRouter from 'vue-router'
import HomePage from '../views/HomePage.vue'
import LogView from '../views/LogView.vue'
import VideoView from '../views/VideoView.vue'
import VideoViewMp4 from '../views/VideoViewMp4.vue'
import VideoViewH264 from '../views/VideoViewH264.vue'

Vue.use(VueRouter)

//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}

const routes = [
  // {
  //   path: '/',
  //   name: 'Manage',
  //   redirect:'/manage/homePage',
  //   component: Manage
  // },
  // {
  //   path: '/manage',
  //   name: 'Manage',
  //   component: Manage,
  //   children: [
  //     {
  //       path: 'homePage',
  //       name: 'HomePage',
  //       component: HomePage,
  //       meta:{
  //         title: 'OLAP管理首页'
  //       }
  //     },
  //   ]
  // },
  {
    path: '/',               // 路由路径
    name: 'homePage',      // 路由名称,为路由提供唯一标识名称,后续可以通过名称跳转路由（this.$router.push({ name: 'HomePage' })）
    component: HomePage,   // 对应的组件，由import后的值决定（与.vue文件中name字段配置的值无关）
    meta: {                  // 元信息
      title: 'vue-demo首页'   // 自定义元数据
    }
  },
  {
    path: '/logView',
    name: 'logView',
    component: LogView,
    meta:{
      title: '日志查看器'
    }
  },
  {
    path: '/videoView',
    name: 'videoView',
    component: VideoView,
    meta:{
      title: '视频查看器'
    }
  },
  {
    path: '/videoViewMp4',
    name: 'videoViewMp4',
    component: VideoViewMp4,
    meta:{
      title: 'MP4视频查看器'
    }
  },
  {
    path: '/videoViewH264',
    name: 'videoViewH264',
    component: VideoViewH264,
    meta:{
      title: 'H264视频查看器'
    }
  }

]

const router = new VueRouter({
  mode: 'hash',
  base: 'k_olap_manager_web',
  routes
})

export default router
